import Vue from "vue";
import Router from "vue-router";
import Home from "./views/Home";
import About from "./views/About";
import Params from "./components/Params";
import Foo from "./components/Foo";
import Bar from "./components/Bar";
import User from "./components/User";
import Articles from "./views/Articles";
import Recommend from "./views/Recommend";
import Download from "./views/Download";
import Login from "./views/Login";

Vue.use(Router);

export default new Router({
  mode: "history",
  base: process.env.BASE_URL,
  routes: [
    {
      path: "/",
      name: "home",
      components: {
        left: Articles,
        right: Recommend
      }
    },
    {
      path: "/about",
      name: "about",
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () =>
        import(/* webpackChunkName: "about" */ "./views/About.vue")
    },
    {
      path: "/foo",
      name: "foo",
      component: Foo
    },
    {
      path: "/bar",
      name: "bar",
      component: Bar
    },
    // 动态路径参数 以冒号开头
    { path: "/user/:id", name: "user", component: User },
    {
      path: "/params/:newsId/:newsTitle",
      name: "params",
      component: Params
    },

    {
      path: "/download",
      name: "Download",
      component: Download
    },
    {
      path: "/login",
      name: "Login",
      component: Login
    },
    {
      path: "/register",
      name: "register",
      component: Login
    }
  ]
});
